<template>
  <h1>EL_表格组件</h1>
  <el-table :data="tableData" style="width: 100%">
    <el-table-column prop="date" label="Date" width="180" />
    <el-table-column prop="name" label="Name" width="180" />
    <el-table-column prop="address" label="Address" />
  </el-table>

  <el-table :data="arr" style="width: 800px; margin:0 auto">
    <el-table-column label="编号" type="index" width="80" align="center" />
    <el-table-column prop="name" label="姓名" width="180" />
    <el-table-column prop="salary" label="工资" width="180" />
    <el-table-column prop="job" label="岗位" />
    <el-table-column label="操作" align="center">
      <template #default="scope">
        <el-button type="danger" @click="del(scope.row,scope.$index)">删除</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>


<script setup>
import {ref} from "vue";

const arr = ref([
  {name:'张三',salary:18000,job:'前端工程师'},
  {name:'李四',salary:18000,job:'后端工程师'},
  {name:'万五',salary:18000,job:'测试工程师'},
  {name:'赵六',salary:18000,job:'工程师'},
]);

const del = (row,index) => {
  if(confirm('您确认要删除'+row.name+'吗？')){
    arr.value.splice(index,1);
  }
}


const tableData = [
  {
    date: '2016-05-03',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-02',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-01',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
]
</script>


<style scoped>

</style>